//
//  LSPopButton.swift
//  新浪微博---01次
//
//  Created by 李宗帅 on 16/5/11.
//  Copyright © 2016年 LS. All rights reserved.
//

import UIKit

class LSPopButton: UIButton {

    override init(frame: CGRect) {
        super.init(frame: frame)
        
        setupUI()
    }
    
    

    required init?(coder aDecoder: NSCoder) {
        fatalError("init(coder:) has not been implemented")
    }

    
    private func setupUI(){
        
        setTitleColor(UIColor.darkGrayColor(), forState: .Normal)
        
        titleLabel?.textAlignment = .Center
        
        titleLabel?.font = UIFont.systemFontOfSize(16)
        
        //属性   按钮图片显得不虚胖?
        imageView?.contentMode = .Center
        
    }
    
    //在这个方法里从新布局系统默认的按钮的布局
    override func layoutSubviews() {
        imageView?.frame.size = CGSizeMake(self.frame.width, self.frame.width)
        imageView?.frame.origin.x = 0
        imageView?.frame.origin.y = 0
        
        
        titleLabel?.frame.size = CGSizeMake(self.frame.width, self.frame.height - self.frame.width)
        titleLabel?.frame.origin.x = 0
        titleLabel?.frame.origin.y = self.frame.size.width
    }
}
